Tool Loop Agent State
Engine-shape state for ToolLoopAgent.
The Vercel AI SDK's Agent interface is stateless per-call — the host passes messages, gets back GenerateResult, manages history itself. For an Android app using a long-lived @AppScope agent (no HTTP boundary, no per-request lifecycle), it's cleaner to treat the agent as a state-holder engine: the agent owns the message log, exposes ToolLoopAgent.engineState as a StateFlow, and the host drives it via ToolLoopAgent.dispatchEngineAction — the same pattern a Compose ViewModel uses for UI state.
The per-call Agent.generate / Agent.stream surface stays available (used by tests and any host that does want stateless calls). The engine surface is layered on top, not a replacement.
Constructors
Properties
Tool calls the model has emitted in the current in-flight step.
True during the engine's first cold load (model init, weights fault-in).
True while a step is actively prefilling/decoding/executing tools.
Finish reason of the most recent completed loop.
Persistent log of all messages — system, user, assistant, tool.
Tool calls awaiting user approval — non-empty pauses the loop.
Text accumulating on the in-flight assistant message, before the step closes.
Total step count across all actions for this agent's lifetime.